
package basis;

import java.sql.*;
import javax.naming.*;

public class DbConnect {
	public synchronized static Connection getConnection()
	{
			Connection conn = null;
			try
			{
				Context initctx = new InitialContext();
				Context ctx = (Context)initctx.lookup("java:comp/env");
				javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("jdbc/mydb");
				conn = ds.getConnection();
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}		
		return conn;
	}
}
